package day1203;

import java.util.Scanner;

public class text {
    public static void main(String[] args) {
        Animal[] a=new Animal[3];
        a[0]=new Fish("小金",2,"金");
        a[1]=new Dog("小金",2,"金");
        a[2]=new Chick("小金",2,"金");
        Master master=new Master();
        for (int i=0;i< a.length;i++)
        {
            System.out.println(a[i].name);
            a[i].eat();
            a[i].drink();
            if(a[i] instanceof Dog){
                Dog dog = (Dog)a[i];
                dog.lookHome();
            }
            if(a[i] instanceof Chick){
                Chick chick = (Chick)a[i];
                chick.layEggs();
            }
            if(a[i] instanceof Swim){ //适用于所有实现Swim接口的(会游泳的)
                Swim s = (Swim)a[i];
                s.swim();
            }
            master.feed(a[i]);
        }
        Scanner sca=new Scanner(System.in);



    }
}
